version: '3'
services:
  # The error pages server
  error-pages:
    image: nginx:latest
    container_name: bitrix-error-pages
    restart: always
    environment:
      TZ: "${SERVER_TIMEZONE}"
    volumes:
      - ./../error-pages/www:/usr/share/nginx/error-pages
      - ./../error-pages/nginx/default.conf:/etc/nginx/conf.d/default.conf
    labels:
      traefik.enable: true

      traefik.http.routers.error-router-ssl.rule: HostRegexp(`{host:.+}`)
      traefik.http.routers.error-router-ssl.priority: 1
      traefik.http.routers.error-router-ssl.entrypoints: https
      traefik.http.routers.error-router-ssl.tls: true
      traefik.http.routers.error-router-ssl.tls.certresolver: ${TRAEFIK_CERT_RESOLVER}
      traefik.http.routers.error-router-ssl.middlewares: error-pages-middleware
      traefik.http.routers.error-router-ssl.service: error-pages

      traefik.http.routers.error-router.rule: HostRegexp(`{host:.+}`)
      traefik.http.routers.error-router.priority: 1
      traefik.http.routers.error-router.entrypoints: http
      traefik.http.routers.error-router.middlewares: error-pages-middleware
      traefik.http.routers.error-router.service: error-pages

      traefik.http.middlewares.error-pages-middleware.errors.status: 400-599
      traefik.http.middlewares.error-pages-middleware.errors.service: error-pages
      traefik.http.middlewares.error-pages-middleware.errors.query: /{status}.html

      traefik.http.services.error-pages.loadbalancer.server.port: 80
    networks:
      - bitrix
